/*!
 * jQuery plugins Tip
 *
 *
 * Date: 2014-05-10 XueJingQue
 * 
 */
define(function(require, exports, module) {

	var $ = require("jquery1.7"); 
  // define plugins
	
  $.fn.pbtip = function(options) {    
	  
   // debug(this);    
    
    // build main options before element iteration    
    var opts = $.extend({}, $.fn.pbtip.defaults, options);
    
    // iterate and reformat each matched element    
    return this.each(function() {
    	
      $this = $(this);    
      
      // build element specific options    
      var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

      var objNewDiv = ""; 

      var text = $this.html();    
      var height = $this.height()+30;
      if(o.direction=="top"){
    	  objNewDiv = $('<div>',{'id':'wt-custom-tip','class':'wt-custom-tip'});
    	  $this.css({    
              position: 'absolute',    
              top: "-"+height+"px", 
              right:"10px"
            });
      }
      
      if(o.show) $this.animate({
    	  top: '10px'
      }, 1000); 
      
      $this.css({    
          display: 'block',    
          color: o.color, 
          background:o.background,
          padding:"26px 8px 10px 13px",
          border:"1px solid #EBEBEB",
          "font-size":"12px"
        });
      
      objNewDiv.append(text);
      
      $this.html(objNewDiv);
   
      if(o.timeout){
    	console.log(o.timeout);
    	  setTimeout(close($this),3000);
      }
      
    });    
  };    
  // debugging private
  function debug($obj) {    
    if (window.console && window.console.log)
      
      window.console.log('tip selection count: ' + $obj.size());    
  };
  
  function close($obj){
	  $obj.stop().fadeOut(1000, function(){
		  $obj.remove();
      });
  }
  $.fn.pbtip.showtip = function() {
	  console.log(111111111111);
	  $(this).css({      
          top: "10px"
        }); 
	  };  
  
  // format function public   
  $.fn.pbtip.setcolor = function(t ,o ,text) {    
    return t.css("color",o.color);    
  };    
  //plugins  defaults    
  $.fn.pbtip.defaults = {
     timeout:0,
     show:false,
     direction:"top",
     color:"#000",
     background:"#F3F3F3"
  };    
// end    
});     
